<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>changed</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="chanctrl.html" title="chanctrl" />
    <link rel="next" href="chani.html" title="chani" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">changed</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="chanctrl.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="chani.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="changed"></a>
      <div class="titlepage"></div>
      <a id="IndexChanged" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">changed</span>
        </h2>
        <p>changed — 
     k-rate signal change detector.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp93396112"></a>
        <h2>Description</h2>
        <p>
	This opcode outputs a trigger signal that informs when any one of its k-rate arguments has changed. Useful with valuator widgets or MIDI controllers.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp93397632"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ktrig <span class="command"><strong>changed</strong></span> kvar1 [, kvar2,..., kvarN]</pre>
      </div>
      <div class="refsect1">
        <a id="idp93459776"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ktrig</em></span> - Outputs a value of 1 when any of the k-rate signals has changed, otherwise outputs 0.
    </p>
        <p>
      <span class="emphasis"><em>kvar1 [, kvar2,..., kvarN]</em></span> - k-rate variables to watch for changes.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp93462576"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the changed opcode. It uses the file <a class="ulink" href="examples/changed.csd" target="_top"><em class="citetitle">changed.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp93464352"></a>
          <p class="title">
            <strong>Example 109. Example of the changed opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac     <span class="comment">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o changed.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="oblock">instr</span> 1

ksig  <span class="opc">oscil</span> 2, 0.5, 1
kint  <span class="op">=</span> <span class="opc">int</span>(ksig)
ktrig <span class="opc">changed</span> kint
      <span class="opc">printk</span> 0.2, kint
      <span class="opc">printk2</span> ktrig

<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 1024 10 1
<span class="stamnt">i</span> 1 0 20

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
            Its output should include lines like:
      </p>
        <pre class="screen">
 i   1 time     0.00267:     0.00000
 i1     0.00000
 i1     1.00000
 i1     0.00000
 i   1 time     0.20267:     1.00000
 i   1 time     0.40267:     1.00000
 i1     1.00000
 i1     0.00000
 i   1 time     0.60267:     1.00000
 i   1 time     0.80267:     1.00000
 i1     1.00000
 i1     0.00000
 i   1 time     1.00000:     0.00000
 i1     1.00000
 i1     0.00000
 i   1 time     1.20267:    -1.00000
 i   1 time     1.40267:    -1.00000
 i1     1.00000
 i1     0.00000
 i   1 time     1.60267:    -1.00000
 i   1 time     1.80000:    -1.00000
 i1     1.00000
 i1     0.00000
 i   1 time     2.00000:    -0.00000
 i1     1.00000
 i1     0.00000
 .........
      </pre>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp93468368"></a>
        <h2>Credits</h2>
        <p>Written by Gabriel Maldonado.</p>
        <p>Example written by Andrés Cabrera.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="chanctrl.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="chani.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">chanctrl </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> chani</td>
        </tr>
      </table>
    </div>
  </body>
</html>
